//
// Created by 李传智 on 2018/4/14.
//

#ifndef ANDSDK_IPLAYER_H
#define ANDSDK_IPLAYER_H


#include <mutex>
#include "VideoThread.h"
#include "CodecParameter.h"
#include "IRecorder.h"

class IDemux;

class IDecode;

class IResample;

class IVideoView;

class IAudioPlay;

class IPlayer : public VideoThread {

public:

    static IPlayer *get(unsigned char index = 0);

    virtual bool setDataSource(const char *url);

    virtual double getCurrentPosition();

    virtual void setPause(bool isPause);

    virtual bool seek(double position);

    virtual void close();

    virtual bool start();

    virtual bool startRecord(const char *url);

    virtual bool stopRecord();

    virtual void setRender(void *window);

    // 视频是否硬解码
    bool isHardDecode = true;

    // 音频输出参数
    CodecParameter audioOutParameter;

    IDemux *demux = 0;

    IDecode *audioDecode = 0;

    IDecode *videoDecode = 0;

    IResample *resample = 0;

    IVideoView *videoView = 0;

    IAudioPlay *audioPlay = 0;

    IRecorder *recorder = 0;

protected:

    IPlayer() {};

    // 用于音视频同步
    void main();

    std::mutex mutex;
};


#endif //ANDSDK_IPLAYER_H
